package com.rppowell.pixie.swing.spriteset;

import java.awt.BorderLayout;

import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;

import com.rppowell.pixie.models.Sprite;
import com.rppowell.pixie.models.SpriteSet;
import com.rppowell.pixie.swing.PixieListener;
import com.rppowell.pixie.swing.sprite.SpriteComboBoxRenderer;

public class SpriteSetListPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	JList<Sprite> spritesetlist;
	JScrollPane spritesetlistscroller;
	
	public SpriteSetListPanel(SpriteSet s) {
		spritesetlist = new JList<Sprite>(new SpriteSetListModel(s));
		spritesetlist.setLayoutOrientation(JList.HORIZONTAL_WRAP);;
		spritesetlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		spritesetlist.setVisibleRowCount(1);
		spritesetlist.setCellRenderer(new SpriteComboBoxRenderer());
		spritesetlist.setSelectedIndex(0);
                spritesetlist.addListSelectionListener(PixieListener.INSTANCE);
                
		spritesetlistscroller = new JScrollPane(spritesetlist);
		spritesetlistscroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		this.setLayout(new BorderLayout());;
		this.add(spritesetlistscroller, BorderLayout.SOUTH);		
	}

}
